<template>
  <div class="box">
    <!-- <el-card> -->
      <div class="header">
        <el-input v-model="input" placeholder="输入道路名称"></el-input>
        <div class="img">
          <img src="@/assets/images/u87.svg" alt="" @click="imgu87" />
          <img src="@/assets/images/u86.svg" alt="" />
          <img src="@/assets/images/u88.svg" alt="" />
          <img src="@/assets/images/u89.svg" alt="" />
          <el-button size="mini" @click="btn">返回</el-button>
        </div>
      </div>
      <div class="content">
        <el-table :data="tableData" style="width: 100%; border-radius: 10px; height: 815px" border
          row-key="investmentId" default-expand-all :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
          >
          <el-table-column type="selection" width="116" align="center" />
          <el-table-column prop="index" label="序号" align="center" width="116">
          </el-table-column>
          <el-table-column prop="investmentType" label="投资类型" align="center">
          </el-table-column>
          <el-table-column prop="investmentYear" label="年份" align="center">
          </el-table-column>
          <el-table-column prop="planInvestmentMoney" label="计划投资金额" align="center">
          </el-table-column>
          <el-table-column prop="doneInvestmentMoney" label="年底前已完成投资（万元）" align="center">
          </el-table-column>
        </el-table>
      </div>
    <!-- </el-card> -->
    <div>
      <el-dialog title="新增投资信息" :visible.sync="dialogVisible" :before-close="handleClose" :show-close="false">
        <el-form :inline="true">
          <el-form-item label="*投资类型">
            <el-input placeholder="输入投资类型" v-model="formData.investmentType"></el-input>
          </el-form-item>
          <el-form-item label="*父级类型">
            <el-input placeholder="输入父级类型" v-model="tableData[0].investmentType" disabled></el-input>
          </el-form-item>
          <el-form-item label="*投资总额（万元）">
            <el-input placeholder="输入投资总额（万元）" v-model="formData.planInvestmentMoney"></el-input>
          </el-form-item>
        </el-form>
        <div class="dialog-footer">
          <el-button type="primary" @click="handleConfirm">提交</el-button>
          <el-button @click="dialogVisible = false">取 消</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>
<script>
import { getInvestmentList, addInvestmentList } from "@/api/collaborativeManagement";
export default {
  props: {
    id: {
      type: Number
    }
  },
  data() {
    return {
      tableData: [
        {
          index: "1",
          roadname: "项目计划总投资",
          street: "2023年",
          height: "300",
          width: "300",
        },
      ],
      input: "",
      queryForm: {
        pageSize: 10,
        pageNum: 1,
      },
      dialogVisible: false,
      formData: {},
    };
  },
  mounted() {
    this.getTableList();
  },
  methods: {
    getTableList() {
      getInvestmentList().then((res) => {
        if (res.code == 200) {
          this.tableData = res.data;
        }
      });
    },
    imgu87() {
      console.log(111);
      this.dialogVisible = true;
    },
    handleConfirm() {
      this.dialogVisible = false;
      this.formData["projectId"] = this.id;
      this.formData['parentId'] = this.tableData[0].investmentId
      this.formData['status'] = 1
      this.formData['remark'] = '空'
      this.formData['doneInvestmentMoney'] = 666
      this.formData['investmentYear'] = 2024
      addInvestmentList(this.formData).then((res) => {
        if (res.code == 200) {
          this.$message({
            type: "success",
            message: "新增成功",
          });
          this.getTableList();
        }
      });
    },
    handleClose() { },
    btn() {
      this.$router.push("index");
    },
  },
};
</script>
<style lang="scss" scoped>
.box {

  // .el-card {
  //   height: 965px;
  // }
  .header {
    width: 100%;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .el-input {
      width: 50%;
    }

    .img {
      width: 200px;
      display: flex;
      justify-content: space-between;

      .el-button {
        background-color: rgb(178, 178, 179);
        color: #ffffff;
      }
    }

    ::v-deep .el-input__inner {
      width: 300px;
      height: 44px;
      border-radius: 10px;
      font-size: 14px;
      border-width: 1px;
      border-style: solid;
      border-color: rgba(215, 215, 215, 1);
    }

    .content {
      height: calc(100% - 60px);
    }
  }

  ::v-deep .el-dialog {
    width: 781px;
    height: 400px;
    border-radius: 20px;
    background-color: #f6f9fb;
    border: none;

    .el-dialog__title {
      font-weight: 650;
      font-size: 20px;
      display: flex;
      justify-content: center;
    }

    .el-form {
      margin-left: 60px;

      .el-form-item__label {
        margin-left: 8px;
        margin-top: -10px;
      }

      .el-form-item {
        width: 310px;

        .el-input__inner {
          width: 300px;
          height: 44px;
          border-radius: 10px;
        }
      }

      .line {
        border-bottom: 1px solid red;
        width: 240px;
        margin-left: 30px;
      }
    }

    .dialog-footer {
      display: flex;
      justify-content: center;
      margin-top: 30px;

      >button:nth-of-type(1) {
        width: 633px;
        height: 54px;
        border-radius: 10px;
        position: absolute;
        bottom: 54px;
      }

      >button:nth-of-type(2) {
        width: 83px;
        height: 36px;
        border-radius: 10px;
        position: absolute;
        right: 15px;
        top: 15px;
      }
    }
  }
}
</style>
